import * as methods from '../../../bk-web-foundation/src/utils'
import * as encrypt from './encrypt'

export default {
  getRealFileName (url) {
    let name = url.split('/').pop()
    if (name.indexOf('_') !== -1) {
      const parts = name.split('.')
      const strs = parts.slice(0, parts.length - 1).join('.').split('_')
      name = strs.slice(0, strs.length - 1).join('_') + '.' + parts.pop()
    }
    return name
  },
  formatDegree (value) {
    if (this.reg.longitude.test(value) || this.reg.latitude.test(value)) {
      const du = value.split('°')[0]
      const fen = value.split('°')[1].split('′')[0]
      const miao = value.split('°')[1].split('′')[1].split('″')[0]
      return Math.abs(du) + (Math.abs(fen) / 60 + Math.abs(miao) / 3600)
    } else {
      value = Math.abs(value)
      const v1 = Math.floor(value)// 度
      const v2 = Math.floor((value - v1) * 60)// 分
      const v3 = parseFloat(((value - v1) * 3600 % 60).toFixed(2))// 秒
      return v1 + '°' + v2 + '′' + v3 + '″'
    }
  },
  ...methods,
  ...encrypt
}
